using System;
using System.Collections.Generic;
using System.Text;
using DTOLayer;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

namespace DAOLayer
{
    public class DAOMonTienQuyet:DataProvider
    {
        public DAOMonTienQuyet()
        {
        }
        public ArrayList LayMang_MonTQ(int maMonHoc)
        {
            connect();
            ArrayList arr = new ArrayList();
            try
            {
                SqlCommand cmd = new SqlCommand("sp_Select_MonTienQuyet", strCnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@maMonHoc", SqlDbType.NVarChar);
                cmd.Parameters["@maMonHoc"].Value = maMonHoc.ToString();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    DTOMonTienQuyet montqdto = new DTOMonTienQuyet();
                    montqdto.MaMonHoc = dr.GetInt32(0);
                    montqdto.MaMonTienQuyet = dr.GetInt32(1);
                    arr.Add(montqdto);
                }
            
                
            }
            catch (Exception es)
            {
                throw es;
            }
            return arr;
        }

        public void insert(DTOMonTienQuyet montqdto)
        {
            connect();
            ArrayList arr = new ArrayList();
            try
            {
                SqlCommand cmd = new SqlCommand("sp_Select_MonTienQuyet", strCnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@maMonHoc", SqlDbType.Int);
                cmd.Parameters["@maMonHoc"].Value = montqdto.MaMonHoc;
                cmd.Parameters.Add("@maMonTQ ", SqlDbType.Int);
                cmd.Parameters["@maMonTQ "].Value = montqdto.MaMonTienQuyet;
                cmd.ExecuteNonQuery();
            }
            catch (Exception es)
            {
                throw es;
            }
        }

       
    }
}
